{% extends 'admin/common/base.html' %}
{% block body %}
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-dict-add">
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">字典名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="name" id="name" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">字典类型：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="dict_type" id="dict_type" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
				    <div class="radio-box">
						<input type="radio" id="6" name="status" value="0" checked="checked">
						<label for="6">正常</label>
					</div>
				    <div class="radio-box">
						<input type="radio" id="7" name="status" value="1">
						<label for="7">停用</label>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<textarea id="remark" name="remark" class="form-control"></textarea>
				</div>
			</div>
		</form>
	</div>
</body>
{% endblock %}
{% block js %}
{{ super() }}
<script type="text/javascript">

    $("#form-dict-add").validate({
        onkeyup: false,
        rules:{
            dict_type:{
                minlength: 5,
                remote: {
                    url: "{{url_for('admin.sys.dict_type.check_dict_type_unique')}}",
                    type: "post",
                    dataType: "json",
                    data: {
                        dict_type : function() {
                            return $.common.trim($("#dict_type").val());
                        }
                    },
                    dataFilter: function(data, type) {
                        return $.validate.unique(data);
                    }
                }
            },
        },
        messages: {
            "dict_type": {
                remote: "该字典类型已经存在"
            }
        },
        focusCleanup: true
    });
    
    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save("{{url_for('admin.sys.dict_type.add')}}", $('#form-dict-add').serialize());
        }
    }
</script>
{% endblock %}
